# Makefile for src/mod/

SHELL = @SHELL@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
MOD_UPDIR = @MOD_UPDIR@

@SET_MAKE@

STRIP = @STRIP@
CXXFLAGS = @CXXFLAGS@ -I../.. -I$(top_srcdir) @DEFS@ $(CFLGS)
CPPFLAGS = @CPPFLAGS@
MOD_CXXFLAGS = @CXXFLAGS@ -I. -I$(MOD_UPDIR)$(top_srcdir)/src -I$(MOD_UPDIR)$(top_srcdir) \
  -I$(MOD_UPDIR)$(top_srcdir)/src/mod -I$(MOD_UPDIR)$(top_srcdir)/lib @DEFS@ $(CFLGS)
MOD_CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@

mods = channels.mod \
	console.mod \
	ctcp.mod \
	irc.mod \
	server.mod \
	share.mod \
	transfer.mod \
	update.mod

mod_objs = channels.mod_o \
	console.mod_o \
	ctcp.mod_o \
	irc.mod_o \
	server.mod_o \
	share.mod_o \
	transfer.mod_o \
	update.mod_o


egg_ac_parameters = @egg_ac_parameters@

MAKE_MOD = $(MAKE) 'MAKE=$(MAKE)' 'CXX=$(CXX)' 'LD=$(LD)' \
'CCDEPMODE=$(CCDEPMODE)' \
'STRIP=$(STRIP)' 'CXXFLAGS=$(MOD_CXXFLAGS)' 'CPPFLAGS=$(MOD_CPPFLAGS)' \
'LIBS=$(LIBS)' 'SHELL=$(SHELL)'


doofus:
	@echo ""
	@echo "Let's try this from the right directory..."
	@echo ""
	@cd ../.. && $(MAKE)

static: build_msg $(mod_objs)

build_msg:
	@echo "[*] Compiling modules"

.SUFFIXES:
.SUFFIXES: .mod .mod_o

.mod.mod_o:
	+@if test ! -d $*.mod; then mkdir $*.mod; fi; \
	if test ! -r $*.mod/Makefile; then \
		cp $(srcdir)/$*.mod/Makefile $*.mod/Makefile; \
	fi; \
	cd $*.mod && $(MAKE_MOD) 'VPATH=$(MOD_UPDIR)$(srcdir)/$*.mod' 'srcdir=$(MOD_UPDIR)$(srcdir)/$*.mod' static;

clean:
	@rm -f *.o *~
	@for i in *.mod; do \
		if test ! -d $$i; then mkdir $$i; fi; \
		if (test ! -r $$i/Makefile) && \
		   (test -r $(srcdir)/$$i/Makefile); then \
			cp $(srcdir)/$$i/Makefile $$i/Makefile; \
		fi; \
		if (test -r $$i/Makefile); then \
			(cd $$i; $(MAKE) "VPATH=$(MOD_UPDIR)$(srcdir)/$$i" "srcdir=$(MOD_UPDIR)$(srcdir)/$$i" 'MAKE=$(MAKE)' clean); \
		fi; \
	done

distclean:
	@rm -f *.o *~
	@for i in *.mod; do \
		if test ! -d $$i; then mkdir $$i; fi; \
		if (test ! -r $$i/Makefile) && \
		   (test -r $(srcdir)/$$i/Makefile); then \
			cp $(srcdir)/$$i/Makefile $$i/Makefile; \
		fi; \
		if (test -r $$i/Makefile); then \
			(cd $$i; $(MAKE) "VPATH=$(MOD_UPDIR)$(srcdir)/$$i" "srcdir=$(MOD_UPDIR)$(srcdir)/$$i" 'MAKE=$(MAKE)' distclean); \
		fi; \
	done


#safety hash
